package com.example.xm.controller;

import com.example.xm.Entity.Dz;
import com.example.xm.servive.DzServive;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/Dz")
public class DzController {
    @Autowired
    DzServive dzServive;

    /**获取*/
    @PostMapping("/search")
    public List<Dz> Mail(@RequestBody Dz dz){
        System.out.println(dzServive.getAllDz(dz));
        return dzServive.getAllDz(dz);
    }

    /**添加地址*/
    @PostMapping("")
    public int Add(@RequestBody Dz dz){
        System.out.println("添加了：" + dz);
        return dzServive.Add(dz);
    }

    /**根据id来获取地址信息*/
    @GetMapping("/{id}")
    public Dz getDzId(@PathVariable String id){
        System.out.println(dzServive.getDzId(id));
        return dzServive.getDzId(id);
    }
    /**修改用户地址*/
    @PutMapping("")
    public int Update(@RequestBody Dz dz){
        System.out.println("修改了：" + dz);
        return dzServive.Update(dz);
    }
}
